//
//  EpointExtendIconView.m
//  EpointFrame5
//
//  Created by 李亚春 on 14-3-22.
//  Copyright (c) 2014年 Epoint. All rights reserved.
//

#import "EpointExtendIconView.h"

@interface EpointExtendIconView()

@end

@implementation EpointExtendIconView

- (id)initWithFrame:(CGRect)frame withHandler:(EpointExtendIconViewTouch)handler
{
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
        self.handler = handler;
        self.ivIcon = [[HJManagedImageV alloc]initWithFrame:CGRectMake(20, 15, 40, 40)];
        [self addSubview:self.ivIcon];
        self.lbTitle = [[UILabel alloc]initWithFrame:CGRectMake(0, 65, 80, 20)];
        self.lbTitle.backgroundColor = [UIColor clearColor];
        [self.lbTitle setFont:[UIFont systemFontOfSize:12]];
        self.lbTitle.textAlignment = NSTextAlignmentCenter;
        [self addSubview:self.lbTitle];
        
        self.ivTips = [[UIImageView alloc]initWithFrame:[EpointExtendIconView getTipShort]];
        [self.ivTips setImage:[UIImage imageNamed:@"img_tips"]];
        self.lbTips = [[UILabel alloc]initWithFrame:self.ivTips.bounds];
        self.lbTips.textColor = [UIColor whiteColor];
        self.lbTips.textAlignment = NSTextAlignmentCenter;
        [self.lbTips setFont:[UIFont systemFontOfSize:13]];
        self.lbTips.backgroundColor = [UIColor clearColor];
        [self.ivTips addSubview:self.lbTips];
        [self addSubview:self.ivTips];
        self.ivTips.hidden = YES;
    }
    return self;
}

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    [super touchesBegan:touches withEvent:event];
    [self setBackgroundColor:COLOR(116, 194, 225)];
}

-(void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event
{
    [super touchesCancelled:touches withEvent:event];
    [self setBackgroundColor:[UIColor clearColor]];
    [self setAlpha:1];
}

-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
    [super touchesEnded:touches withEvent:event];
    [self setBackgroundColor:[UIColor clearColor]];
    [self setAlpha:1];
    self.handler();
}

+(CGRect)getTipLongRect
{
    return CGRectMake(46, 9, 28, 22);
}

+(CGRect)getTipShort
{
    return CGRectMake(49, 9, 22, 22);
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
    // Drawing code
}
*/

@end
